<?
global $AppUI;

$uid = $_REQUEST['user'];
$date = $_REQUEST['date'];

$q = new DBQuery();
$q->addTable('task_log', 'l');
$q->addQuery('l.*, t.task_id, p.project_id, p.project_name');
$q->addJoin('tasks', 't', 't.task_id = l.task_log_task');
$q->addJoin('projects', 'p', 'p.project_id = t.task_project');
$q->addWhere('l.task_log_creator = '.$uid);
$q->addWhere('DATE(l.task_log_date) = "'.$date.'"');
$q->addOrder('p.project_name');
$logs = $q->loadHashList('task_log_id');

$date = new CDate(str_replace('-', '', $date));
$date = $date->format($AppUI->getPref('SHDATEFORMAT'));
?>
<div style="border: 1px solid #999">
<div style="border-bottom: 1px solid #999; background: #FFFFC8; color: #8B0000; height: 16px; padding: 2px">
<b><?=$date?></b>
</div>
<div style="width: 100%; height: 220px; overflow-x: hidden; overflow-y: auto" onresize="doDetailResize(this)">
<table id="idTableLog" border="0" cellpadding="2" cellspacing="0" width="100%" class="internal">
<?
$project = '';
foreach ($logs as $id => $log) {
	if ($project != $log['project_name']) {
		$project = $log['project_name'];
?>
<tr>
	<td colspan="4" style="border-bottom: 1px solid #999; background: #F0F0F0" align="left">
		<b><?=$project?></b>
	</td>
</tr>
<?
	}
?>
<tr>
	<td style="border-bottom: 1px solid #DDD"><img src="images/task.gif"/></td>
	<td colspan="2" style="border-bottom: 1px solid #DDD" align="left" valign="top" width="100%">
		<?=html_entity_decode($log['task_log_name'])?>
	</td>
	<td style="border-bottom: 1px solid #DDD" valign="top" align="right">
		<?=number_format($log['task_log_hours'], 2)?>h
	</td>
</tr>
<tr>
	<td style="border-bottom: 1px solid #999">&nbsp;</td>
	<td colspan="3" style="border-bottom: 1px solid #999; padding-left: 16px" align="left" valign="top">
		<?=str_replace("\n", '<br/>', $log['task_log_description'])?>
	</td>
</tr>
<?
	}
?>
</table>
</div>
</div>
